/** 
 * OutputStreamLog.java
 * @author Lex
 * 2007-8-17 ����11:48:36
 */
package fun.util;

import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.Writer;

public class StreamLog implements Log {
	protected PrintWriter writer = null;

	public StreamLog() {
		this(System.out);
	}

	/*
	 * ���紫�ݽ�����OutputStreamΪnull��Ĭ����Ϊ�Ὣ��¼������System.out
	 */
	public StreamLog(OutputStream out) {
		this(new OutputStreamWriter(null == out ? System.out : out));
	}

	public StreamLog(Writer out) {
		if (null == out)
			out = new OutputStreamWriter(System.out);
		this.writer = new PrintWriter(out, true);
	}

	public Log error(Object msg) {
		return this.print(msg);
	}

	public Log fine(Object msg) {
		return this.print(msg);
	}

	public Log info(Object msg) {
		return this.print(msg);
	}

	protected Log print(Object msg) {
		this.writer.print(msg);
		this.writer.flush();
		return this;
	}
}
